/**   
 * Copyright (C) 2019-2020 UnitSpirit and wupf
 *
 * This file is part of UnitSpirit.
*/
package cn.luischen;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import org.apache.catalina.Session;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.alibaba.fastjson.JSON;
import com.google.gson.Gson;

/**
 * @author wupf
 *
 */
public class Abc {
	private static final Logger logger = LoggerFactory.getLogger(Abc.class);

	ThreadLocal<Session> startTime = new ThreadLocal<>();
	/**
	 * @category
	 * @author wupf 
	 * @date 2020年7月8日 上午11:54:19 
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			Abc cAbc=new Abc();
			final Map<String, String> mapProxy = new HashMap<String, String>();
			
			logger.info(mapProxy.get(null));
			logger.info(new Gson().toJson(cAbc.startTime));
			String str2 = "{\"attributeNames\":[],\"creationTime\":1585187502740,\"id\":\"06748A23377D69373E0BB84444B59228\",\"lastAccessedTime\":1585187505400,\"maxInactiveInterval\":1800,\"new\":false,\"servletContext\":{\"attributeNames\":[\"javax.servlet.context.tempdir\",\"org.apache.catalina.resources\",\"org.springframework.web.context.WebApplicationContext.ROOT\",\"org.springframework.web.context.support.ServletContextScope\",\"org.apache.tomcat.InstanceManager\",\"org.apache.catalina.jsp_classpath\",\"javax.websocket.server.ServerContainer\",\"org.apache.tomcat.JarScanner\",\"org.springframework.web.servlet.FrameworkServlet.CONTEXT.dispatcherServlet\"],\"contextPath\":\"\",\"defaultSessionTrackingModes\":[\"COOKIE\",\"URL\"],\"effectiveMajorVersion\":3,\"effectiveMinorVersion\":0,\"effectiveSessionTrackingModes\":[\"COOKIE\",\"URL\"],\"filterRegistrations\":{\"requestContextFilter\":{\"className\":\"org.springframework.boot.web.servlet.filter.OrderedRequestContextFilter\",\"initParameters\":{},\"name\":\"requestContextFilter\",\"servletNameMappings\":[],\"urlPatternMappings\":[\"/*\"]},\"Tomcat WebSocket (JSR356) Filter\":{\"className\":\"org.apache.tomcat.websocket.server.WsFilter\",\"initParameters\":{},\"name\":\"Tomcat WebSocket (JSR356) Filter\",\"servletNameMappings\":[],\"urlPatternMappings\":[\"/*\"]},\"httpPutFormContentFilter\":{\"className\":\"org.springframework.boot.web.servlet.filter.OrderedHttpPutFormContentFilter\",\"initParameters\":{},\"name\":\"httpPutFormContentFilter\",\"servletNameMappings\":[],\"urlPatternMappings\":[\"/*\"]},\"hiddenHttpMethodFilter\":{\"className\":\"org.springframework.boot.web.servlet.filter.OrderedHiddenHttpMethodFilter\",\"initParameters\":{},\"name\":\"hiddenHttpMethodFilter\",\"servletNameMappings\":[],\"urlPatternMappings\":[\"/*\"]},\"characterEncodingFilter\":{\"className\":\"org.springframework.boot.web.servlet.filter.OrderedCharacterEncodingFilter\",\"initParameters\":{},\"name\":\"characterEncodingFilter\",\"servletNameMappings\":[],\"urlPatternMappings\":[\"/*\"]},\"webStatFilter\":{\"className\":\"com.alibaba.druid.support.http.WebStatFilter\",\"initParameters\":{\"exclusions\":\"*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*\"},\"name\":\"webStatFilter\",\"servletNameMappings\":[],\"urlPatternMappings\":[\"/*\"]}},\"initParameterNames\":[],\"majorVersion\":3,\"minorVersion\":1,\"serverInfo\":\"Apache Tomcat/8.5.29\",\"servletContextName\":\"application\",\"servletNames\":[],\"servletRegistrations\":{\"default\":{\"className\":\"org.apache.catalina.servlets.DefaultServlet\",\"initParameters\":{\"listings\":\"false\",\"debug\":\"0\"},\"mappings\":[],\"name\":\"default\"},\"dispatcherServlet\":{\"className\":\"org.springframework.web.servlet.DispatcherServlet\",\"initParameters\":{},\"mappings\":[\"/\"],\"name\":\"dispatcherServlet\"},\"statViewServlet\":{\"className\":\"com.alibaba.druid.support.http.StatViewServlet\",\"initParameters\":{},\"mappings\":[\"/druid/*\"],\"name\":\"statViewServlet\"}},\"servlets\":[],\"sessionCookieConfig\":{\"httpOnly\":false,\"maxAge\":-1,\"secure\":false},\"sessionTimeout\":30,\"virtualServerName\":\"Tomcat/localhost\"},\"sessionContext\":{\"ids\":[]},\"valueNames\":[]}";

			Session cSession = JSON.parseObject(str2, Session.class);
			cAbc.startTime.set(cSession);
			logger.info(new Gson().toJson(cAbc.startTime.get()));
			String str=new Gson().toJson(cAbc.startTime);
			logger.info(str);
			ThreadLocal<Session> startTime2=new Gson().fromJson(str, ThreadLocal.class);
			logger.info(new Gson().toJson(startTime2.get()));
			
			Generic<Integer> genericInteger = new Generic<Integer>(123456);

			//传入的实参类型需与泛型的类型参数类型相同，即为String.
			Generic<String> genericString = new Generic<String>("key_vlaue");
			logger.info("泛型测试","key is " + genericInteger.getKey());
			logger.info("泛型测试","key is " + genericString.getKey());
			logger.info(genericInteger.getKey().getClass().toString());
			logger.info(genericString.getKey().getClass().toString());
			//System.out.println(cPageInfo.getEndRow());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	static class def {
		int i = 0;

		int add(int j) {
			return j + 1;
		}
	}

	private class dprivate {
		int i = 0;

		int add(int j) {
			return j + 2;
		}

	}

	public class dpublic {
		int add(int j) {
			return j + 3;
		}

	}

	class d1 {
		int add(int j) {
			return j + 4;
		}

	}
}
